package com.laiyizhan.common.mapper;

import com.laiyizhan.common.model.App;
import org.apache.ibatis.annotations.*;

public interface AppMapper {
    @Delete({
        "delete from t_apps",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into t_apps (app_id, app_secret, ",
        "platform)",
        "values (#{appId,jdbcType=INTEGER}, #{appSecret,jdbcType=VARCHAR}, ",
        "#{platform,jdbcType=VARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(App record);

    int insertSelective(App record);

    @Select({
        "select",
        "id, app_id, app_secret, platform",
        "from t_apps",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    App selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(App record);

    @Update({
        "update t_apps",
        "set app_id = #{appId,jdbcType=INTEGER},",
          "app_secret = #{appSecret,jdbcType=VARCHAR},",
          "platform = #{platform,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(App record);

    @Select({"select app_secret from t_apps where app_id = #{appId,jdbcType=INTEGER}"})
    String selectByAppId(Integer integer);
}